#include<iostream>
#include<iomanip>
using namespace std;
//char s[1000];
int main()
{
	int n,m,a[55][55];
	int cnt = 0;
	cin >> n >> m;
	for (int i=0;i<n;i++)
		for (int j=0;j<m;j++)
			cin >> a[i][j];
	
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		{
			bool ismax = true;
			bool ismin = true;
			for (int mmm=0;mmm<m;mmm++)
			{
				if (a[i][mmm]>a[i][j])
				{
					ismax = false;
					break;
				}
			}
			
			for (int nnn=0;nnn<n;nnn++)
			{
				if (a[nnn][j]<a[i][j])
				{
					ismin = false;
					break;
				}
			}
			if (ismax && ismin)
			 cnt++;			
		}	
	}			
			
	/*		
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		{			
			cout << setw(5) << a[i][j] ;
		}
		cout << endl;
	}*/
	cout << cnt << endl;
	return 0;
}



